<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ page import="java.util.Locale" %>


<fmt:bundle basename="StripesResources" /> 
<fmt:message key='menu.play' var="play" />
<s:layout-render name="layout.jsp" nadpis="${play}">

    <s:layout-component name="telo">
        <s:useActionBean beanclass="cz.muni.fi.pa165.hauntedhouses.rest.web.PlayActionBean" var="actionBean"/>        
        <s:errors/>
        <br />        
        <s:form beanclass="cz.muni.fi.pa165.hauntedhouses.rest.web.PlayActionBean">
            <c:choose>
                <c:when test="${actionBean.houses.size() == 0}">
                    <div><font style="color: red"><fmt:message key="play.nohouses"/></font></div><br/>
                </c:when>
                <c:otherwise>
                    <fmt:message key="play.selecthouse"/>
                    <table class="zakladni">
                        <tr>
                            <th></th>
                            <th><fmt:message key="play.name"/></th>
                            <th><fmt:message key="play.address"/></th>
                            <th><fmt:message key="play.countofhumans"/></th>
                            <th><fmt:message key="admin.houseHistory"/></th>
                        </tr>
                        <c:forEach items="${actionBean.houses}" var="house">
                            <tr>
                                <td style="width: 15px;">
                                    <s:radio name="house.id" value="${house.id}" />
                                </td>

                                <td><c:out value="${house.name}"/></td>
                                <td><c:out value="${house.address}"/></td>
                                <td><c:out value="${house.humans.size()}"/></td>
                                <td><c:out value="${house.history}"/></td>

                            </tr>
                        </c:forEach>
                    </table>
                </c:otherwise>
            </c:choose>
            <br /><br />
            <c:choose>
                <c:when test="${actionBean.ghosts.size() == 0}">
                    <div><font style="color: red"><fmt:message key="play.noghosts"/></font></div><br/>
                </c:when>
                <c:otherwise>
                    <fmt:message key="play.selectghost"/>
                    <table class="zakladni">

                        <tr>
                            <th></th>
                            <th><fmt:message key="play.name"/></th>
                            <th><fmt:message key="play.level"/></th>
                            <th><fmt:message key="play.experience"/></th>
                            <th><fmt:message key="play.lasthaunted"/></th>
                            <th><fmt:message key="play.abilitytype"/></th>
                            <th><fmt:message key="play.countofabilities"/></th>
                        </tr>
                        <c:forEach items="${actionBean.ghosts}" var="ghost">
                            <tr>
                                <td style="width: 15px;">
                                    <s:radio name="ghost.id" value="${ghost.id}" />
                                </td>
                                <td><c:out value="${ghost.name}"/></td>
                                <td><c:out value="${ghost.lvl}"/></td>
                                <td><c:out value="${ghost.experience}"/></td>
                                <td><fmt:formatDate value="${ghost.lastHaunted}" pattern="MM/dd/yyyy"/> </td>
                                <td><c:out value="${ghost.abilityType}"/></td>
                                <td><c:out value="${ghost.abilities.size()}"/></td>
                            </tr>
                        </c:forEach>
                    </table>
                </c:otherwise>
            </c:choose>
            <br />
            
            <s:submit style="width: 210px;height: 30px" name="play2">
                <fmt:message key="play.next"/>
            </s:submit>
        </s:form>
    </s:layout-component>
</s:layout-render>
